package com.manor.paradise.adapter.npcshop

import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.manor.common.utils.DpUtil
import com.manor.paradise.R
import com.manor.paradise.bean.GiftsBean

class GiftsAdapter(layoutResId: Int, data: MutableList<GiftsBean.RecordsBean>?) : BaseQuickAdapter<GiftsBean.RecordsBean, BaseViewHolder>
(layoutResId, data) {
    var requestOptions = RequestOptions().transform(CenterCrop(), RoundedCorners(DpUtil.dp2px(16)))
    override fun convert(baseViewHolder: BaseViewHolder, item: GiftsBean.RecordsBean) {
        var im_img = baseViewHolder.getView<ImageView>(R.id.im_img)

        Glide.with(context).load(item.imgUrl)
                .apply(requestOptions)
                .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL))
                .into(im_img)
        var tv_name = baseViewHolder.getView<TextView>(R.id.tv_name)
        tv_name.setText(item.name)
    }
}

